﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using mock_ehr_lib.Model;

namespace mock_ehr_lib.View.MainTabs
{
    public partial class History : UserControl
    {
        public History()
        {
            InitializeComponent();
            Load += historyLoad;
            MockEHRApplication.Instance.OnPatientChanged += onPatientChanged;
        }

        void historyLoad(object sender, EventArgs e)
        {
            var patientSummary = MockEHRApplication.Instance.CurrentPatient.Summary;
            if (patientSummary != null)
            {
                dgvFamilyHistory.DataSource = patientSummary.FamilyHistory;
                dgvSocialHistory.DataSource = patientSummary.SocialHistory;
            }
        }

        void onPatientChanged(Patient newPatient)
        {
            historyLoad(this, null);
        }
    }
}
